package com.kaoshi.servefw.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kaoshi.servefw.domain.Stables;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author Lenovo
* @description 针对表【stables】的数据库操作Mapper
* @createDate 2024-10-29 14:48:06
* @Entity com.kaoshi.servefw.domain.Stables
*/
public interface StablesMapper extends BaseMapper<Stables> {

    List<Stables> findPage(Page<Stables> stablesPage, Stables stables);

//    @Select("select s.*,dew.*,dew.name dewname from stables s left join dwellers dew on s.dewid = dew.id where s.id = #{id}")

    @Select(" select s.*,a.name aname,age.name agename,d.name dname,dew.*,dew.name dewname,t.name tname,p.name pname,h.*,sou.name sname,m.*,m.name mname\n" +
            "        from\n" +
            "        stables s\n" +
            "        left join\n" +
            "        address a\n" +
            "        on\n" +
            "        s.aid=a.id\n" +
            "        left join\n" +
            "        agencies age\n" +
            "        on\n" +
            "        s.ageid=age.id\n" +
            "        left join\n" +
            "        doctor d\n" +
            "        on\n" +
            "        s.did=d.id\n" +
            "        left join\n" +
            "        dwellers dew\n" +
            "        on\n" +
            "        s.dewid=dew.id\n" +
            "        left join\n" +
            "        team t\n" +
            "        on\n" +
            "        s.tid=t.id\n" +
            "        left join\n" +
            "        packs p\n" +
            "        on\n" +
            "        s.pid=p.id\n" +
            "        left join\n" +
            "        source sou\n" +
            "        on\n" +
            "        s.sid=sou.id\n" +
            "        left join\n" +
            "        health h\n" +
            "        on\n" +
            "        s.hid=h.id\n" +
            "        left join\n" +
            "        mfily m\n" +
            "        on\n" +
            "        dew.mid=m.id\n" +
            "         where s.id = #{id}")
    Stables findById(Integer id);

    List<Stables> findPageSr(Page<Stables> stablesPage, Stables stables);



//    Stables findByid(Integer id);
}




